<template>
	<view class="suspend">
		<view class="title">
			<view class="left">
				排钟时刻表
			</view>
			<view class="right" @click="tableDataFun">
				刷新
			</view>
		</view>
		<view class="table" v-if="tableData.length!=0">
			<thead>
				<tr>
					<th>技师工号</th>
					<th>技师姓名</th>
					<!-- <th>当前状态</th> -->
					<th>排序</th>
					<th>备注</th>
				</tr>
			</thead>
			<tbody>
				<tr v-for="(item, index) in tableData" :key="index">
					<th>{{ item.jobNumber }}</th>
					<th>{{ item.name }}</th>
					<!-- <th>{{ item.type }}</th> -->
					<th>{{ item.sort }}</th>
					<th>无</th>
				</tr>
			</tbody>
		</view>
		<u-empty v-else mode="list">
		</u-empty>
	</view>
</template>

<script>
	import {
		gettechnicianList,
		webAppletList
	} from '@/api/system/work'
	export default {
		props: {
			// storeId: Number, // 声明message属性
			storeId: {
				type: Number,
				default: 0
			}
		},
		watch: {
			storeId: {
				handler(newVal, oldVal) {
					this.storeId = newVal
					this.gettechnicianList()
				}
			}
		},
		data() {
			return {
				timeItem: '',
				shopVisible: false,
				timeList: ['20分钟', '40分钟', '60分钟', '100分钟'],
				tableData: [],
				pickerForm: {},
				ruleForm: {},
				roles: '',
				name: '',
				userId: '',
				// storeId: ''
			}
		},
		created() {
			this.gettechnicianList()
			const userId = uni.getStorageSync('userId');
			this.userId = userId
			const roles = uni.getStorageSync('role');
			this.roles = roles
		},
		mounted() {
			this.gettechnicianList()
			const userId = uni.getStorageSync('userId');
			this.userId = userId
			const roles = uni.getStorageSync('role');
			this.roles = roles
		},
		methods: {
			gettechnicianList() {
				if(this.roles=='technician'){
					const userId = uni.getStorageSync('userId');
					// {userId:userId}
					gettechnicianList({	storeId: this.storeId}).then(res=>{
						this.tableData=res.data
					})
				}
				// else{
				// const date = new Date();
				// const year = date.getFullYear();
				// const month = String(date.getMonth() + 1).padStart(2, '0');
				// const day = String(date.getDate()).padStart(2, '0');
				// const hours = String(date.getHours()).padStart(2, '0');
				// const minutes = String(date.getMinutes()).padStart(2, '0');
				// webAppletList({
				// 	date: `${year}-${month}-${day}`,
				// 	storeId: this.storeId,
				// 	time: `${hours}:${minutes}`
				// }).then(res => {
				// 	// this.tableData = res.rows
				// 	this.tableData = res.rows.map((rItem) => {
				// 		let minute = rItem.serviceEndTime ? Math.round((Number(rItem.serviceEndTime)) - Date.now()) : 0;
				// 		return {
				// 			...rItem,
				// 			type: minute ? `需等待${minute}分钟` :'空闲',
				// 			value: rItem.id,
				// 			serviceEndTime: rItem.serviceEndTime ? rItem.serviceEndTime : null,
				// 		};

				// 	});
				// })
				// }

			},

			tableDataFun() {
				this.gettechnicianList()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.suspend {
		.title {
			display: flex;
			justify-content: space-between;
			line-height: 108rpx;

			.left {
				font-size: 50rpx;
				font-weight: 500;
				color: #000000;
			}

			.right {
				color: #C27E15;
			}

			// margin: 43rpx 0;
		}

		.table {
			color: #000000;
			background-color: #fff;
			padding: 15rpx;
			border-radius: 16rpx;
			font-size: 30rpx;

			tr {
				display: flex;
				justify-content: space-around;

				th {
					width: 150rpx;
					text-align: center;
					padding: 5rpx 8rpx;
				}
			}
		}
	}
</style>